<?php
namespace Common\Common;
class GatewayHandle {

private $gateway;

function __construct($gateway){
	if($gateway)
		$this->gateway=$gateway;
	else
		$this->gateway=U('Gateway/securepay@'. $_SERVER['SERVER_NAME']);
}

/**
*接口处理方法
*@param array $post_arr 提交的是必要参数的数组
*@return array 返回支付结果的数组
*/
public function run($post_arr){
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $this->gateway);
	curl_setopt($ch,CURLOPT_POST,1);
	curl_setopt($ch,CURLOPT_POSTFIELDS,http_build_query($post_arr));
	curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
	$response = curl_exec($ch);
	curl_close($ch);
	$back_data=json_decode($response,true);
	return $back_data;
}
	
}